home *** CD-ROM | disk | FTP | other *** search
/ TPUG - Toronto PET Users Group / TPUG Users Group CD / TPUG Users Group CD.iso / AMIGA / AMICUS / AMICUS02.ADF / Make / rules.c < prev    next >
C/C++ Source or Header  |  1989-05-30  |  1KB  |  66 lines

  1.  
  2. /* rules.c */
  3.  
  4. #include "rules.h"
  5. extern int debug;
  6.  
  7. AddDependant( pch_name, pch_target )
  8.    char *pch_name, *pch_target;
  9. {
  10.    int pos;
  11.  
  12.    pos = _Lookup( pch_target );
  13.    if( debug )
  14.       printf("Found %s at pos %d\n", pch_target, pos );
  15.    arl_Rules[ pos ].apch_depend[ arl_Rules[ pos ].c_depend++ ] = pch_name;
  16. }
  17.  
  18. char **
  19. GetDependants( pch_target )
  20.    char *pch_target;
  21. {
  22.    int pos;
  23.  
  24.    pos = _Lookup( pch_target );
  25.    return arl_Rules[ pos ].apch_depend;
  26. }
  27.  
  28. AddAction( pch_action, pch_target )
  29.    char *pch_action, *pch_target;
  30. {
  31.    int pos;
  32.  
  33.    pos = _Lookup( pch_target );
  34.    if( debug )
  35.       printf("Found %s at pos %d\n", pch_target, pos );
  36.    arl_Rules[ pos ].apch_action[ arl_Rules[ pos ].c_action++ ] = pch_action;
  37. }
  38.  
  39. char **
  40. GetActions( pch_target )
  41.    char *pch_target;
  42. {
  43.    int pos;
  44.  
  45.    pos = _Lookup( pch_target );
  46.    return arl_Rules[ pos ].apch_action;
  47. }
  48.  
  49. int n_Rules = 0;
  50. struct rule arl_Rules[ MAXRULES ];
  51.  
  52. _Lookup( pch_target )
  53.    char *pch_target;
  54. {
  55.    int pos = 0;
  56.  
  57.    arl_Rules[ n_Rules ].pch_target = pch_target;
  58.    arl_Rules[ n_Rules ].c_action = 0;
  59.    arl_Rules[ n_Rules ].c_depend = 0;
  60.    while( strcmp( arl_Rules[pos].pch_target , pch_target ) )
  61.       pos++;
  62.    if ( pos == n_Rules )
  63.       n_Rules++;
  64.    return pos;
  65. }
  66.